<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>表单</title>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css">
    <link rel="stylesheet" href="__PUBLIC__/static/css/style.css">
    <link rel="icon" href="__PUBLIC__/static/image/code.png">
</head>
<body class="body">
<div class="tab-top layui-box">
  <a class="layui-btn site-demo-active layui-btn-sm" id="addview" data-href=""><i class="layui-icon layui-icon-add-circle"></i>玩家信息表</a>
<div class="search">
  <form class="layui-form" action="">
       <div class="layui-input-inline top-search-date">
        <input type="text" name="searchdate" id="date1" autocomplete="off"  class="layui-input layui-input-sm" placeholder=" 开始时间 - 结束时间" value="{$searchdate}">
      </div>  
        <div class="layui-input-inline">
        <select name="search" lay-verify="required" class="search-name" lay-search="">
          <option value="chrname" {$search=='chrname' ? 'selected=""' : ''}>玩家名</option>
          <input type="hidden" name="id" value="{$id}">
        </select>
      </div>
  <div class="layui-inline">
    <input class="layui-input layui-input-sm" name="val" placeholder="请输入" id="search-elm" autocomplete="off" value="{$val}">
  </div>
  <button class="layui-btn site-demo-active layui-btn-sm search-btn" data-type="reload">搜索</button>
</form>
</div>
</div>

<div class="system-table-1 layui-clear" style="padding-top:10px;">

<div class="layui-btn-group demoTable" id="demoTable">
  <div class="layui-btn-group">
  <button class="layui-btn" data-href="{:url('admin/Game/getout')}" data-type="getOut">踢下线</button>
  <button class="layui-btn" data-href="{:url('admin/Game/getdownlin')}" data-type="getDownlin">封号</button>
  <button class="layui-btn" data-href="{:url('admin/Game/getunsealuser')}" data-type="getUnsealip">解封</button>
</div>
<div class="layui-btn-group">
  <button class="layui-btn" data-href="{:url('admin/Game/getnospeak')}" data-type="getNospeak">禁言</button>
  <button class="layui-btn" data-href="{:url('admin/Game/getspeak')}" data-type="getSpeak">解禁言</button>
</div>
<div class="layui-btn-group">
  <button class="layui-btn" data-href="{:url('admin/Game/getsealip')}" data-type="getSealip">封ip</button>
  <button class="layui-btn" data-href="{:url('admin/Game/getunsealip')}" data-type="getUnsealip">解封ip</button>
</div>

<!-- <div class="layui-btn-group">
  <button class="layui-btn" data-href="{:url('admin/Game/getsealuser')}" data-type="getSealip">封帐号</button>
  <button class="layui-btn" data-href="{:url('admin/Game/getunsealuser')}" data-type="getUnsealip">解封帐号</button>
</div> -->

  <div class="layui-btn-group">
  <button class="layui-btn" data-href="{:url('admin/Game/getstealth')}" data-type="getStealth">玩家隐身</button>
  <button class="layui-btn" data-href="{:url('admin/Game/getnostealth')}" data-type="getNostealth">取消隐身</button>
</div>
<div class="layui-btn-group">
  <button class="layui-btn" data-href="{:url('admin/Game/getgm')}" data-type="getGm">GM命令</button>
  <button class="layui-btn" data-href="{:url('admin/Game/getslelct')}" data-type="getSlelct">属性查询</button>
</div>
</div>

<table class="layui-table" lay-filter="parse-table-demo" lay-data="{height:'full-120',url:'{:url('admin/Game/ajaxplayer',\Request::param())}', page:true, id:'test',limit:'{:config('webconfig.page')}'}">
  <thead>
    <tr>
      <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
      <th lay-data="{field:'server_id', width:80, sort: true}">ID</th>
      <th lay-data="{field:'seedname', width:230}">玩家id</th>
      <th lay-data="{field:'account', width:180}">玩家帐号</th>
      <th lay-data="{field:'chrname', width:150}">昵称</th>
      <th lay-data="{field:'lv', width:80}">等级</th>
      <th lay-data="{field:'job', width:180}">职业</th>
      <th lay-data="{field:'gender', width:80}">性别</th>
      <th lay-data="{field:'vip_level', width:80}">vip等级</th>
      <th lay-data="{field:'online', width:100}">是否在线</th>
      <th lay-data="{field:'lastip', width:200}">最后离开时间|ip</th>
      <th lay-data="{fixed: 'right', width:128, align:'center', toolbar: '#barDemo'}">查看详细</th>
    </tr> 
  </thead>
</table>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="show"><i class="layui-icon">&#xe642;</i></a>
</script>
</div>
<!-- 通用-970*90 -->
<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<script src="__ADMIN__/js/comm.js" charset="utf-8"></script>
<script type="text/javascript">
layui.use(['form', 'table', 'laydate'], function() {
  var $ = layui.jquery,
    form = layui.form,
    laydate = layui.laydate,
    table = layui.table;

  //日期时间范围
  laydate.render({
    elem: '#date1',
    type: 'datetime',
    range: true
  });


  //监听工具条
  table.on('tool(parse-table-demo)', function(obj) {
    var id = obj.data.account;
    // console.log(data.account);
    var userinfo = obj.data.userinfo;
    if (obj.event === 'show') {

      layer.open({
        title: userinfo + " —— 详细信息",
        type: 2,
        area: ['450px', '500px'],
        fixed: false, //不固定
        maxmin: true,
        content: "{:url('admin/Game/show')}?id=" + id
      });

    }
  });
  //layer.alert(JSON.stringify(data));
  //var url = "{:url('admin/Game/')}";
  // $('.demoTable .layui-btn').on('click', function(){
  //   var type = $(this).data('type');
  //   active[type] ? active[type].call(this) : '';
  // });

  $('#demoTable .layui-btn').click(function(event) {
    var checkStatus = table.checkStatus('test'),
      data = checkStatus.data;
    //console.log($(this).data('type'));
    if (!data.length) {
      layer.msg('请先选择要操作数据');
      return;
    }
    //var id = data[0].account;
    //var name = data[0].chrname;
    var url = $(this).data('href');

    if (($(this).data('type') === 'getGm')) { //GM 命令操作
      layer.prompt({
		  formType: 2,
		  area: ['400px','25px'],
		  value: '',
		  title: '请输入GM命令'
		},function(val, pindex) {
        $.each(data, function(index, el) {
          //console.log(data);
          name = data[index].chrname;
          id = data[index].account;
          console.log(url, name, val, id);
          getpostcmd(url, name, val, id);
        }); // body...
        layer.close(pindex);
      });


    } else if (($(this).data('type') === 'getSlelct')) { //属性查询

    } else { //快捷操作
      $.each(data, function(index, el) {
        //console.log(data);
        name = data[index].chrname;
        id = data[index].account;
        console.log(url, name, id);
        getpost(url, name, id);
      });
    }
  });


  function getpost(url, name, id) {
    $.post(url, {
      id: id,
      name: name
    }, function(data) {
      console.log(data);
      if (data.code == 1) {
        layer.msg(data.msg);
      } else {
        layer.msg(data.msg);
      }
    });
  }


  function getpostcmd(url, name, val, id) {
    //layer.prompt(function(val, index) {
    $.post(url, {
      id: id,
      name: name,
      cmd: val
    }, function(data) {
      if (data.code == 1) {
        layer.msg(data.msg);
      } else {
        layer.msg(data.msg);
      }
    });
  }

});






</script>



</body>
</html>